package com.example.oom;

import cn.hutool.core.lang.UUID;
import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode;
import org.apache.kafka.common.protocol.types.Field;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author csp 2023-09-04
 */
public class OomTest {

    /**
     * 模拟线程OOM的场景
     *
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        System.out.println("Started..");

//        int MAX_SIZE = 1000000;
//        Thread[] arrays = new Thread[MAX_SIZE];
//        for (int i = 0; i < MAX_SIZE; ++i) {
//            int finalI = i;
//            arrays[i] = new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    System.out.println("线程：" + arrays[finalI].getName());
//                }
//            });
//            arrays[i].start();
//            Thread.sleep(10);
//        }
        for (int i = 0; i < 8; i++) {
            new Thread(() -> {
                while (true) {
                }
            }).start();
        }
    }



}
